﻿<!--
Copyright 2003-2009 Virtual Chemistry, Inc. (VCI)
http://www.virtualchemistry.com
Using .Net, Silverlight, SharePoint and more to solve your tough problems in web-based data management.

Author: Peter Coley
-->
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Vci.Silverlight.FileUploader"
	mc:Ignorable="d"
	x:Class="Vci.Silverlight.FileUploader.FileListItemControl"
	d:DesignWidth="640" d:DesignHeight="100" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">
    <UserControl.Resources>
        <local:ByteConverter x:Key="ByteConverter" />
        <Style x:Key="ImageButtonStyle" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center">
                                <ContentPresenter.Content>
                                    <Image Source="{TemplateBinding Content}" ></Image>
                                </ContentPresenter.Content>
                            </ContentPresenter>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Storyboard x:Name="sbProgress">
        	<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(RangeBase.Value)">
        		<SplineDoubleKeyFrame x:Name="sbProgressFrame" KeyTime="00:00:00.5000000" Value="10"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <Border x:Name="LayoutRoot" BorderThickness="0,0,0,1" BorderBrush="#FFA3AEB9">
		<vsm:VisualStateManager.VisualStateGroups>
			<vsm:VisualStateGroup x:Name="UploadStates">
				<vsm:VisualState x:Name="Pending">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
				<vsm:VisualState x:Name="Uploading">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
				<vsm:VisualState x:Name="Canceling">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
				<vsm:VisualState x:Name="Canceled">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
				<vsm:VisualState x:Name="Error">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
				<vsm:VisualState x:Name="Finished">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00.2000000">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
				<vsm:VisualState x:Name="Processing">
					<Storyboard>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
						</DoubleAnimationUsingKeyFrames>
						<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="progressPercent" Storyboard.TargetProperty="(UIElement.Opacity)">
							<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
						</DoubleAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Collapsed</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</vsm:VisualState>
			</vsm:VisualStateGroup>
		</vsm:VisualStateManager.VisualStateGroups>
		<Grid Height="Auto" Margin="4,4,4,4" x:Name="panelFile" Width="Auto">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="0.627*"/>
				<ColumnDefinition Width="80"/>
				<ColumnDefinition Width="120"/>
				<ColumnDefinition Width="22"/>
			</Grid.ColumnDefinitions>
            <TextBlock Height="Auto" Width="Auto" Text="{Binding Path=FileName}" ToolTipService.ToolTip="{Binding Path=FileName}" TextWrapping="NoWrap" x:Name="txtName" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Center" />
    		<TextBlock Height="Auto" Width="Auto" Text="{Binding Path=State}" TextWrapping="Wrap" x:Name="txtState" HorizontalAlignment="Center" Margin="0,0,0,0" Grid.Column="2" VerticalAlignment="Center"/>
    		<TextBlock Height="Auto" Text="{Binding Converter={StaticResource ByteConverter}, Path=FileSize}" TextWrapping="NoWrap" x:Name="txtSize" TextAlignment="Right" HorizontalAlignment="Right" Margin="0,0,8,0" Width="Auto" Grid.Column="1" VerticalAlignment="Center"/>
    		<ProgressBar x:Name="progressPercent" Opacity="1" Visibility="Visible" Margin="0,0,0,0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="120" Height="16"/>
    		<Button Width="10" Content="x3.png" x:Name="btnRemove" Click="btnRemove_Click" HorizontalAlignment="Right" Margin="0,0,2,0" Style="{StaticResource ImageButtonStyle}" Height="10" Grid.Column="3" d:LayoutOverrides="Height" VerticalAlignment="Center" Cursor="Hand" ToolTipService.ToolTip="Remove this file from the list."/>
    		<Button Width="14" Content="tool_cancel.png" x:Name="btnCancel" Click="btnCancel_Click" HorizontalAlignment="Right" Margin="0,0,0,0" Style="{StaticResource ImageButtonStyle}" Height="14" Grid.Column="3" d:LayoutOverrides="Height" VerticalAlignment="Center" Cursor="Hand" ToolTipService.ToolTip="Cancel the current upload."/>
    	</Grid>
	</Border>
</UserControl>